package org.corey.wyp.command
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import mx.collections.Sort;
	import mx.collections.SortField;
	import mx.controls.Alert;
	import mx.rpc.IResponder;
	
	import org.corey.wyp.business.PropertyManagerDelegate;
	import org.corey.wyp.event.MonthAccountShowEvent;
	import org.corey.wyp.model.ProperityModelLocator;
	import org.corey.wyp.vo.Month;
	
	public class MonthAccountShowCommand implements ICommand,IResponder
	{
		public function MonthAccountShowCommand()
		{
		}
		
		public function execute(event:CairngormEvent):void{
			var showEvent:MonthAccountShowEvent=MonthAccountShowEvent(event);
			var year:int=showEvent.year;
			var month:int=showEvent.month;
			var pm:PropertyManagerDelegate=new PropertyManagerDelegate(this);
			pm.getMonth(year,month);
		}
		
		public function result(event:Object):void{
			var m:Month=Month(event.result);
			ProperityModelLocator.getInstance().application.accountMonth=m;
			var sort:Sort=new Sort();
			sort.fields=[new SortField("date",false)];
			ProperityModelLocator.getInstance().application.accountMonth.days.sort=sort;
			ProperityModelLocator.getInstance().application.accountMonth.days.refresh();
		}
		
		public function fault(info:Object):void{
			Alert.show("增加信息失败:"+info);
		}
	}
}